<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="参建单位" bodyClass="white-bg" libs=["bootstrapSelect"]/>
<div class="wrapper wrapper-content ibox-content">
    <@f.form id="task-form-complete" class="form-horizontal">
    <h4 class="form-header h4"><@ctx.i18n text = "基本信息"/></h4>
    <input class="form-control" name="id" value="${participant.id?default('')}" type="hidden"   >

    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "参建编号"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->

                        <input class="form-control" name="participantCode" value="${participant.participantCode?default('')}" type="text"  placeholder="参建编号自动生成" readonly >
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "参建名称"/>：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="participantName" value="${participant.participantName?default('')}" type="text"  >
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "工程编号"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->

                        <input class="form-control" name="projectCode" value="${participant.projectCode?default('')}" type="text" placeholder="工程编号自动生成" readonly >
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "工程名称"/>：</label>
                <div class="col-sm-8">

                    <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->

                    <input class="form-control" name="projectName" value="${participant.projectName?default('')}" type="text" placeholder="请输入工程名称"  >

                </div>
            </div>
        </div>

    </div>
    <div class="row">

        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-2 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "行政区划"/>：</label>
                <div class="col-sm-10">
                    <@f.treeselect id="wholeName" name="region" boxTitle="请选择行政区划" url="sys/area/treeData"  keyName="wholeName" keyId="name"
                    value="${participant.region}" labelValue="${participant.region}"
                    checked=true correlationId="parentId"  placeholder="请选择行政区划"/>
                    <!--<input class="form-control" name="region" value="" type="text"  >-->
                </div>
            </div>
        </div>

    </div>


    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-2 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "工程类别"/>：</label>
                <div class="col-sm-8">
                    <!--<input class="form-control" name="projectType" value="" type="text"  >-->
                    <input class="form-control" name="testingIndustry" value="" type="hidden"  >
                    <@f.radio name="projectType" dictType="project_type" value="${participant.projectType?default('')}"/>
                </div>
            </div>
        </div>

        <!--<div class="col-sm-6">-->
        <!--<div class="form-group">-->
        <!--<label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "登记员"/>：</label>-->
        <!--<div class="col-sm-8">-->
        <!--<input class="form-control" name="registerName" value="" type="text"  >-->

        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "监理姓名"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->

                        <!--<input class="form-control" name="supervisorName" value="" type="text"  >-->
                        <@f.tableselect checked=false keyId="userName" keyName="userName" url="/pms/participantUser/list"
                        value="${participant.supervisorName}" labelValue="${participant.supervisorName}"
                        name="supervisorName" boxTitle="监理姓名" tableInfo = "[{field:'userCode',title:'人员编号'},
                        {field:'userName',title:'人员姓名'}, {field:'iphone',title:'人员电话'},{field:'participantUnit',title:'所属单位'}]"
                        placeholder="请选择监理姓名" />
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "监理手机"/>：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="supervisorCode" value="${participant.supervisorCode?default('')}" type="hidden"  >
                    <input class="form-control" name="supervisorIphone" value="${participant.supervisorIphone?default('')}" type="text"  >
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "甲方姓名"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
                        <@f.tableselect checked=false keyId="userName" keyName="userName" url="/pms/participantUser/list"
                        value="${participant.firstName}" labelValue="${participant.firstName}"
                        name="firstName" boxTitle="甲方姓名" tableInfo = "[{field:'userCode',title:'人员编号'},
                        {field:'userName',title:'人员姓名'}, {field:'iphone',title:'人员电话'},{field:'participantUnit',title:'所属单位'}]"
                        placeholder="请选择监理姓名" />
                        <!--<input class="form-control" name="firstName" value="" type="text"  >-->
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "甲方手机"/>：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="firstCode" value="${participant.firstCode?default('')}" type="hidden"  >
                    <input class="form-control" name="firstIphone" value="${participant.firstIphone?default('')}" type="text"  >
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "施工人姓名"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
                        <@f.tableselect checked=false keyId="userName" keyName="userName" url="/pms/participantUser/list"
                        value="${participant.buildName}" labelValue="${participant.buildName}"
                        name="buildName" boxTitle="甲方姓名" tableInfo = "[{field:'userCode',title:'人员编号'},
                        {field:'userName',title:'人员姓名'}, {field:'iphone',title:'人员电话'},{field:'participantUnit',title:'所属单位'}]"
                        placeholder="请选择监理姓名" />

                        <!--<input class="form-control" name="buildName" value="" type="text"  >-->
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "施工人手机"/>：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="buildCode" value="${participant.buildCode?default('')}" type="hidden"  >
                    <input class="form-control" name="buildIphone" value="${participant.buildIphone?default('')}" type="text"  >
                </div>
            </div>
        </div>
    </div>


    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">
                    <span style="color: red; ">*</span>状态：</label>
                <div class="col-sm-8">
                    <@f.radio name="participantStatus" dictType="project_status" value="${participant.participantStatus?default('')}"/>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-2 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "备注"/>：</label>
                <div class="col-sm-10">
                    <!--readonly="false"-->
                    <textarea class="form-control" name="remark" >${participant.remark?default('')}</textarea>
                    <!--<@f.textarea name="remarks"/>-->
                </div>
            </div>
        </div>
    </div>


</div>




</@f.form>
<div class="hr-line-dashed"></div>
<div class="row" style="text-align: center;" id="_addTab">
    <!--<button type="button" class="btn btn-sm btn-primary" onclick="opt.form.submit()"><i class="fa fa-check"></i><@ctx.i18n text = "保存"/></button>&nbsp;-->
    <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i><@ctx.i18n text = "保存"/></button>&nbsp;
    <button type="button" class="btn btn-sm btn-danger" onclick="opt.modal.closeTab()"><i class="fa fa-reply-all"></i><@ctx.i18n text = "关闭"/></button>
</div>
</div>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "pms/participant";

    $('#tipBut button').click(function(){
        $('#comment').text($(this).text())
    });

    $("#task-form-complete").validate({
        focusCleanup: true
    });

    /**
     * 利用redio 组件回调事件处理 数据权限数据控制显示还是隐藏
     * 回传两个参数 name 当前控制名称, data 当前点击对象, event 事件对象
     **/
    function redioCallback(name, data, event){
        if(name == "projectType"){
            console.log(data)
            if ($(data).is(':checked')){
                console.log(data.value)
                $("input[name=testingIndustry]").val(data.value);

            }
        }
    }

    function tableCallback(id, event, index, layero, nodes){
        console.log("aaaaaaaaaaaaaaa")
        console.log(id)
        console.log("aaaaaaaaaaaaaaa")
        if(id == "supervisorName"){
            console.log("弹出表格选择===>>>>: id:" + id + "  event:" + event + " index:" + index + "  layero:"+ layero + " nodes:" + JSON.stringify(nodes));
            console.log(nodes.table[0]);
            var data = nodes.table[0];
            $("input[name=supervisorIphone]").val(data.iphone);
            $("input[name=supervisorCode]").val(data.userCode);
        }
        if(id == "firstName"){
            console.log("弹出表格选择===>>>>: id:" + id + "  event:" + event + " index:" + index + "  layero:"+ layero + " nodes:" + JSON.stringify(nodes));
            console.log(nodes.table[0]);
            var data = nodes.table[0];
            $("input[name=firstIphone]").val(data.iphone);
            $("input[name=firstCode]").val(data.userCode);
        }
        if(id == "buildName"){
            console.log("弹出表格选择===>>>>: id:" + id + "  event:" + event + " index:" + index + "  layero:"+ layero + " nodes:" + JSON.stringify(nodes));
            console.log(nodes.table[0]);
            var data = nodes.table[0];
            $("input[name=buildIphone]").val(data.iphone);
            $("input[name=buildCode]").val(data.userCode);
        }


    }

    function submitHandler() {

        //  var arrivalAmount= parseFloat($('input[name="arrivalAmount"]').val());
        //  var claimAmount= parseFloat($('input[name="claimAmount"]').val());
        //  console.log(arrivalAmount);
        //  console.log(claimAmount);
        //  console.log(claimAmount>arrivalAmount);
        // if(claimAmount>arrivalAmount){
        //   //  alert("已认领金额不能大于到账金额");
        //   return  opt.modal.alertWarning("已认领金额不能大于到账金额");
        // }

        if (opt.validate.form()) {
            opt.operate.saveTab(prefix + "/edit", $('#task-form-complete').serialize());
        }
    }
</script>
</@footer>
</@pageTheme>